﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inheritance_abstract_polymorphism
{
    class TrueFalseQuiz : QuizBase
    {
        private bool _correctAnswer;
        private bool _inputAnswer;

        public TrueFalseQuiz(string question,
                            QuizType type,
                            QuizDifficulty difficulty,
                            bool correcAnswer)
            : base(question, type, difficulty)
        {
            _correctAnswer = correcAnswer;
        }

        public override void ReadAnswer()
        {
            bool bConvertResult = false;
            do 
            {
                bConvertResult = bool.TryParse(Console.ReadLine().Trim(),out _inputAnswer);
                if(!bConvertResult)
                {
                    Console.WriteLine("Ban hay nhap TRUE hoac FALSE");
                }
            } while (!bConvertResult);
        }

        public override bool IsCorrect()
        {
            if (_inputAnswer == _correctAnswer)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        public override void ShowQuestion()
        {
            Console.WriteLine("Day la cau hoi dung sai. Ban hay nhap TRUE hoac FALSE");
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(this.Question);
            Console.ForegroundColor = ConsoleColor.Gray;
        }
    }
}
